package com.pig4cloud.pigx.contract.executer.order.supporter;

import com.pig4cloud.pigx.common.customize.enums.CommonDictEnum;
import com.pig4cloud.pigx.contract.dto.ContractOrderNewDTO;
import com.pig4cloud.pigx.contract.entity.ContractPosition;
import com.pig4cloud.pigx.contract.enums.ContractOrderEnum;

import java.math.BigDecimal;

/**
 * OrderExecutor辅助功能类
 *
 * @since 2022/8/31 16:01
 */
public class OrderSupporter {
    /**
     * 根据仓位生成强平订单
     *
     * @param position  仓位
     * @param markPrice 标记价
     * @return {@link ContractOrderNewDTO}
     * @since 2022/8/31 16:14
     * @deprecated 目前采用直接修改仓位、钱包余额的强平方式
     */
    @Deprecated
    public static ContractOrderNewDTO getOrderLiquidateByPosition(ContractPosition position, BigDecimal markPrice) {
        ContractOrderNewDTO dto = new ContractOrderNewDTO();
        dto.setUserId(position.getUserId());
        dto.setSymbolId(position.getSymbolId());
        dto.setType(ContractOrderEnum.Type.LIQUIDATE.getValue());
        dto.setPositionId(position.getId());
        dto.setPositionMode(position.getMode());
        dto.setSide(position.getSide());
        dto.setOperationType(ContractOrderEnum.OperationType.CLOSE.getValue());
        dto.setIsRobot(CommonDictEnum.YesOrNo.NO.getValue());
        dto.setPrice(markPrice);
        dto.setNum(position.getNowNum());
        dto.setMultiple(position.getMultiple());

        return dto;
    }
}
